#-*- coding:utf8 -*-
#/usr/bin/env python
'''
日志保存 使用python的日志模块
'''

import logging.handlers
import logging
import logging.config

import conf

class Logger(object):
        
    @staticmethod
    def GetLogger():
        # Set up a specific logger with our desired output level
        root = logging.getLogger('root')
        if len(root.handlers) == 0:  # 避免重复
            filename = conf.LOG_FILE_PATH
#            handler = logging.handlers.RotatingFileHandler(filename, 'a', 10*1024*1024, 5)
            handler = logging.handlers.TimedRotatingFileHandler(filename, "midnight", 1, 5)
            format = '%(asctime)s - %(pathname)s - %(filename)s[line:%(lineno)d] - %(levelname)s - %(message)s'
            fmt = logging.Formatter(format) 
            handler.setFormatter(fmt)
            root.addHandler(handler)
            root.setLevel(conf.LOG_LEVEL)
        return root


if __name__ == '__main__':
#    logger = Logger.getLogger()
    
    Logger.GetLogger().info("aaadafadfada")
    Logger.GetLogger().debug("aaafasdfadfgsffdfadfaa")
    
    
    
    
